require("../../@babel/runtime/helpers/Arrayincludes");

var e = getApp();

Component({
    properties: {},
    data: {
        channelsLive: null,
        liveSettingInfo: {},
        is_open: !1,
        openPages: []
    },
    ready: function() {
        var e = wx.getStorageSync("yz_basic_info").plugin_setting;
        e && e.video_live_room && 1 == e.video_live_room && this.getLiveSetting();
    },
    methods: {
        openChannelsLive: function() {
            var e = this.data.channelsLive;
            wx.openChannelsLive({
                finderUserName: this.data.liveSettingInfo.video_id,
                feedId: e.feedId,
                nonceId: e.nonceId
            });
        },
        getLiveSetting: function() {
            var n = this, t = e.getNetAddresss("plugin.video-live-room.frontend.index.get-data");
            e._getNetWork({
                showToastIn: !1,
                url: t,
                success: function(e) {
                    var t = e.data;
                    1 == t.result && (n.setData({
                        liveSettingInfo: t.data
                    }), n.checkOpen());
                }
            });
        },
        checkOpen: function() {
            if (1 == this.data.liveSettingInfo.is_open) {
                var e = this.data.liveSettingInfo.display_page.split(",");
                e.includes("1") && this.data.openPages.push("packageG/index/index"), e.includes("2") && this.data.openPages.push("packageA/detail_v2/detail_v2");
                var n = getCurrentPages(), t = n[n.length - 1];
                console.log(this.data.liveSettingInfo, "page"), this.data.openPages.includes(t.route) && this.getChannelsLiveInfo();
            }
        },
        getChannelsLiveInfo: function() {
            var n = this;
            console.log("当前页面需要显示", this.data.liveSettingInfo), wx.getChannelsLiveInfo && wx.getChannelsLiveInfo({
                finderUserName: this.data.liveSettingInfo.video_id,
                success: function(e) {
                    n.data.channelsLive = e, n.setData({
                        is_open: !0
                    });
                },
                fail: function(n) {
                    console.log(n), e.tips("请检查视频号ID与小程序是否同个主体或者视频号是否开过直播", "none", 3500);
                }
            });
        }
    }
});